#include "CGame.h"
CGame::CGame()
{
}
CGame::~CGame()
{
}
void CGame::Start()
{
    CPlayer player1 = CPlayer(1);
    CPlayer player2 = CPlayer(-1);
    CBoard myboard = CBoard();
    CJudge judgeman = CJudge();
    AI computer = AI();
    int row, column, gameover = 0;
    int com_row, com_column;
    int judge_x, judge_y;
    myboard.board[7][7]=1;
    myboard.Refresh();
    myboard.board[6][7]=-1;
    myboard.Refresh();
    while (gameover == 0)
    {
        int judge_result = 2;
        while (judge_result > 1)
        {
            cout << "玩家1输入坐标判断禁手" << endl;
            cin >> judge_x >> judge_y;
            judge_result = judgeman.ForbiddenJudge(myboard, judge_x, judge_y);
        }
        player1.Set(myboard);
        row = player1.GetRow();
        column = player1.GetColumn();
        if (judgeman.JudgeWin(myboard, PLAYER1, row, column))
        {
            cout << "玩家1获胜" << endl;
            gameover = 1;
            break;
        }
        myboard.board[row][column] = 2;
        myboard.Refresh();
        computer.AISet(myboard);
        com_row = computer.GetAIRow();
        com_column = computer.GetAIColumn();
        if (judgeman.JudgeWin(myboard, COMPUTER, com_row, com_column))
        {
            cout << "电脑获胜" << endl;
            gameover = 1;
            break;
        }
        myboard.board[com_row][com_column] = -1;
        myboard.Refresh();
    }
    cout << "Game Over" << endl;
}
